home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Leonardo the Inventor
/
Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso
/
LEOWINMV
/
DATABASE.DIR
/
00113_Script_BUILD INDEX
< prev
next >
Wrap
Text File
|
1996-03-28
|
3KB
|
60 lines
-- --------------------------------------------------------
-- Handler buildIndex builds an index out of the contents
-- of a database. It builds the index from fields that
-- are next to each other in the cast window (and therefore
-- receives the parameters "fromCast" and "toCast")
on buildIndex fromCast, toCast
repeat with i = fromCast to toCast -- cast numbers of relevant fields
set currentField = the text of cast i
repeat with j = 1 to the number of words in currentField
set currentWord = word j of currentField
if not(isIgnorableWord(currentWord)) then
if endsWithPunctuation(currentWord) then
set currentWord = removePunctuation(currentWord)
end if
set indexCast = the number of cast (currentWord && "INDEX")
if (indexCast <> -1) then -- a field of topics containing the current word already exists
set temp = the text of cast indexCast
put RETURN & the name of cast i after temp
put temp into cast indexCast
else -- a field of topics containing the current word doesn't exist
set newFieldNumber = findEmpty(cast (toCast+ 5))
put the name of cast i into cast newFieldNumber
set the name of cast newFieldNumber = currentWord && "INDEX"
end if
end if
end repeat
end repeat
end
-- --------------------------------------------------------
-- Handler alphabetizeCasts alphabetizes the casts from
-- "fromCast" to "toCast"
on alphabetizeCasts fromCast, toCast
-- get a temporary cast to use for moving casts around
set tempCast = findEmpty(cast toCast)
put "TEMP" into cast tempCast
set the name of cast tempCast = "tempCast"
-- bubble sort (n-1) factorial times
repeat with i = fromCast to toCast - 1
repeat with j = i+1 to toCast - 1
set firstCast = i
set secondCast = j
set firstName = the name of cast firstCast
set secondName = the name of cast secondCast
if (firstName > secondName) then -- switch the casts around
set the name of cast tempCast = the name of cast firstCast
put the text of cast firstCast into cast tempCast
set the name of cast firstCast = the name of cast secondCast
put the text of cast secondCast into cast firstCast
set the name of cast secondCast = the name of cast tempCast
put the text of cast tempCast into cast secondCast
set the name of cast tempCast = "tempCast"
put "TEMP" into cast tempCast
end if
end repeat
end repeat
end